/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ps.client;

import com.ps.server.BDLocal;
import com.ps.server.DefaultMutableTreeNodeIdName;
import com.ps.server.classes.*;
import java.util.Hashtable;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.table.DefaultTableModel;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import net.atlanticbb.tantlinger.shef.HTMLEditorPane;

/**
 *
 * @author Ricardo
 */
public class mainForm extends javax.swing.JFrame {

    Hashtable configuration;
    Vector<products> bdproducts;
    Vector<categories> bdcategories;
    Vector<manufacturers> bdmanufacturers;
    Vector<combinations> bdcombinations;
    Vector<languages> bdlanguages;
    Hashtable bdtaxes;
    Hashtable bdtax_rules;
    Hashtable bdtax_rule_groups;
    BDLocal bd;
    //Vector <taxes> bdtaxes;

    /**
     * Creates new form mainForm
     */
    private void loaddata() {
        bd = new BDLocal("products");
        this.bdproducts = bd.getData();
        bd = new BDLocal("categories");
        this.bdcategories = bd.getData();
        bd = new BDLocal("manufacturers");
        this.bdmanufacturers = bd.getData();
        bd = new BDLocal("combinations");
        this.bdcombinations = bd.getData();
        bd = new BDLocal("languages");
        this.bdlanguages = bd.getData();
        bd = new BDLocal("configurations");
        this.configuration = bd.getConfig();
        bd = new BDLocal("taxes");
        this.bdtaxes = bd.getConfig();

        configurations co = (configurations) this.configuration.get("PS_LANG_DEFAULT");
        bd = new BDLocal("tax_rules",co.getValue());
        this.bdtax_rules = bd.getConfig();
        bd = new BDLocal("tax_rule_groups");
        this.bdtax_rule_groups = bd.getConfig();
    }

    public mainForm() {
        initComponents();
        loaddata();
        importData();
    }

    public String getNamelanguage(String[][] namelang) {
        String name = "";
        configurations co = (configurations) this.configuration.get("PS_LANG_DEFAULT");
        for (int x = 0; namelang.length > x; x++) {
            if (namelang[x][0].equals(co.getValue())) {
                name = namelang[x][1];
            }
        }
        return name;
    }

    private void productTable(String idprod) {
        //BDLocal bd = new BDLocal("products");

        //String[] nomecolumn = new String[]{"id", "nome", "quantità", "prezzo", "ref"};
        //Object[][] ModelData = new Object[5][metadata.length];
        //this.MetaData = data.get(0).GetMetaData();


        Vector metadata = new Vector();
        metadata.addElement("id");
        metadata.addElement("nome");
        metadata.addElement("quantita");
        metadata.addElement("prezzo");
        metadata.addElement("ref");

        Vector modelproduct = new Vector();
        for (int row = 0; this.bdproducts.size() > row; row++) {
            if (this.bdproducts.get(row).getId_category_default().equals(idprod)) {
                Vector rowpro = new Vector(metadata.size());
                rowpro.addElement(this.bdproducts.get(row).getId());
                rowpro.addElement(getNamelanguage(this.bdproducts.get(row).getName()));
                rowpro.addElement(this.bdproducts.get(row).getPrice());
                rowpro.addElement(this.bdproducts.get(row).getPrice());
                rowpro.addElement(this.bdproducts.get(row).getReference());
                modelproduct.add(rowpro);
                /*
                 * Object [] rowpro = new Object[]{
                 * this.bdproducts.get(row).getId(),
                 * this.bdproducts.get(row).getName().toString(),
                 * this.bdproducts.get(row).getQuantity(),
                 * this.bdproducts.get(row).getPrice(),
                 * this.bdproducts.get(row).getReference()
                 */
                //};
            }

            /*
             * this.ModelData[row][0] = data.get(row).getId();
             * this.ModelData[row][1] = data.get(row).getId_manufacturer();
             * this.ModelData[row][2] = data.get(row).getId_supplier();
             * this.ModelData[row][3] = data.get(row).getId_category_default();
             * this.ModelData[row][4] = data.get(row).getOut_of_stock();
             * this.ModelData[row][5] = data.get(row).getNewproduct();
             * this.ModelData[row][6] =
             * data.get(row).getCache_default_sttribute();
             * this.ModelData[row][7] = data.get(row).getId_default_image();
             * this.ModelData[row][8] =
             * data.get(row).getId_default_combination(); this.ModelData[row][9]
             * = data.get(row).getReference(); this.ModelData[row][10] =
             * data.get(row).getSupplier_reference(); this.ModelData[row][11] =
             * data.get(row).getLocation(); this.ModelData[row][12] =
             * data.get(row).getEan13(); this.ModelData[row][13] =
             * data.get(row).getUpc(); this.ModelData[row][14] =
             * data.get(row).getUnity(); this.ModelData[row][15] =
             * data.get(row).getId_tax_rules_group(); this.ModelData[row][16] =
             * data.get(row).getId_color_default(); this.ModelData[row][17] =
             * data.get(row).getMinimal_quantity(); this.ModelData[row][18] =
             * data.get(row).getPrice(); this.ModelData[row][19] =
             * data.get(row).getAdditional_shipping_cost();
             * this.ModelData[row][20] = data.get(row).getWholesale_price();
             * this.ModelData[row][21] = data.get(row).isOn_sale();
             * this.ModelData[row][22] = data.get(row).isOnline_only();
             * this.ModelData[row][23] = data.get(row).getEcotax();
             * this.ModelData[row][24] = data.get(row).getUnit_price();
             * this.ModelData[row][25] = data.get(row).getWidth();
             * this.ModelData[row][26] = data.get(row).getHeigth();
             * this.ModelData[row][27] = data.get(row).getDepth();
             * this.ModelData[row][28] = data.get(row).getWeight();
             * this.ModelData[row][29] = data.get(row).isQuantity_discount();
             * this.ModelData[row][30] = data.get(row).getCustomizable();
             * this.ModelData[row][31] = data.get(row).getUploadable_files();
             * this.ModelData[row][32] = data.get(row).getText_fields();
             * this.ModelData[row][33] = data.get(row).isActive();
             * this.ModelData[row][34] = data.get(row).isAvailable_for_order();
             * this.ModelData[row][35] = data.get(row).getCondition();
             * this.ModelData[row][36] = data.get(row).isShow_price();
             * this.ModelData[row][37] = data.get(row).isIndexed();
             * this.ModelData[row][38] = data.get(row).isCache_is_pack();
             * this.ModelData[row][39] =
             * data.get(row).isCache_has_attachments(); this.ModelData[row][40]
             * = data.get(row).getQuantity(); this.ModelData[row][41] =
             * data.get(row).getMeta_description(); this.ModelData[row][42] =
             * data.get(row).getMeta_keywords(); this.ModelData[row][43] =
             * data.get(row).getMeta_title(); this.ModelData[row][44] =
             * data.get(row).getLink_rewrite(); this.ModelData[row][45] =
             * data.get(row).getName(); this.ModelData[row][46] =
             * data.get(row).getAvailable_now(); this.ModelData[row][47] =
             * data.get(row).getAvailable_later(); this.ModelData[row][48] =
             * data.get(row).getDescription(); this.ModelData[row][49] =
             * data.get(row).getDescription_short(); this.ModelData[row][50] =
             * data.get(row).getCategories(); this.ModelData[row][51] =
             * data.get(row).getImages(); this.ModelData[row][52] =
             * data.get(row).getCombinations(); this.ModelData[row][53] =
             * data.get(row).getProduct_option_values(); this.ModelData[row][54]
             * = data.get(row).getProduct_features(); this.ModelData[row][55] =
             * data.get(row).getTags();
             */

        }
        DefaultTableModel tableModel = new DefaultTableModel(modelproduct, metadata);

        this.jTable1.setModel(tableModel);
    }

    private void importData() {
        CargarArbol();
        DefaultTreeModel modelo = new DefaultTreeModel(raiz);
        this.jTree2.setModel(modelo);

    }
    DefaultMutableTreeNode raiz;
    //Vector<categories> data;

    void CargarArbol() {

        //this.bdcategories = bd.getData();
//configurations co = (configurations) this.configuration.get("PS_HOME_CATEGORY");
        Vector<categories> dataelement = getElement("");
        DefaultMutableTreeNodeIdName nodoCanton;
        for (int x = 0; dataelement.size() > x; x++) {
            raiz = new DefaultMutableTreeNodeIdName(dataelement.get(x).getId(), dataelement.get(x).getName()[0][1]);
            Vector<categories> element = getElement(this.bdcategories.get(x).getId());
            for (int y = 0; element.size() > y; y++) {
                nodoCanton = new DefaultMutableTreeNodeIdName(element.get(y).getId(), element.get(y).getName()[0][1]);
                raiz.add(nodoCanton);
                ObtenerHijo(element.get(y).getId(), nodoCanton);
            }
        }
    }

    private Vector getElement(String idpadre) {
        Vector<categories> element = new Vector<categories>();
        for (int x = 0; this.bdcategories.size() > x; x++) {
            if (idpadre.trim().equals(this.bdcategories.get(x).getId_parent().trim())) {
                element.add(this.bdcategories.get(x));
            }
        }
        return element;
    }

    private void ObtenerHijo(String idpadre, DefaultMutableTreeNodeIdName node) {
        Vector<categories> hijos;
        hijos = getElement(idpadre);
        DefaultMutableTreeNodeIdName nodoHijo;
        if (hijos.size() > 0) {
            for (int x = 0; hijos.size() > x; x++) {
                nodoHijo = new DefaultMutableTreeNodeIdName(hijos.get(x).getId(), hijos.get(x).getName()[0][1]);
                node.add(nodoHijo);
                ObtenerHijo(hijos.get(x).getId(), nodoHijo);
            }
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jOptionPane1 = new javax.swing.JOptionPane();
        jSplitPane2 = new javax.swing.JSplitPane();
        jSplitPane1 = new javax.swing.JSplitPane();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTree2 = new javax.swing.JTree();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTable3 = new javax.swing.JTable();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTable4 = new javax.swing.JTable();
        jPanel3 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jTextField1 = new javax.swing.JTextField();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        openMenuItem = new javax.swing.JMenuItem();
        saveMenuItem = new javax.swing.JMenuItem();
        saveAsMenuItem = new javax.swing.JMenuItem();
        exitMenuItem = new javax.swing.JMenuItem();
        editMenu = new javax.swing.JMenu();
        cutMenuItem = new javax.swing.JMenuItem();
        copyMenuItem = new javax.swing.JMenuItem();
        pasteMenuItem = new javax.swing.JMenuItem();
        deleteMenuItem = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        contentMenuItem = new javax.swing.JMenuItem();
        aboutMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jSplitPane2.setDividerSize(10);
        jSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        jSplitPane1.setDividerLocation(100);
        jSplitPane1.setDividerSize(10);

        jTree2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTree2MouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(jTree2);

        jSplitPane1.setLeftComponent(jScrollPane2);

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable1MouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTable1);

        jTable3.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane3.setViewportView(jTable3);

        jTable4.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null},
                {null},
                {null},
                {null},
                {null},
                {null},
                {null},
                {null},
                {null},
                {null}
            },
            new String [] {
                "Img"
            }
        ));
        jScrollPane4.setViewportView(jTable4);

        jPanel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 136, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 123, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 406, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 386, Short.MAX_VALUE)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );

        jSplitPane1.setRightComponent(jPanel2);

        jSplitPane2.setRightComponent(jSplitPane1);

        jButton1.setText("Attributi e Gruppi");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Caratteristiche");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setText("Produttori");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton4.setText("Lingue");

        jTextField1.setText("jTextField1");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton4)
                        .addContainerGap(329, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(126, 126, 126))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2)
                    .addComponent(jButton3)
                    .addComponent(jButton4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(35, Short.MAX_VALUE))
        );

        jSplitPane2.setLeftComponent(jPanel1);

        fileMenu.setMnemonic('f');
        fileMenu.setText("File");

        openMenuItem.setMnemonic('o');
        openMenuItem.setText("Open");
        fileMenu.add(openMenuItem);

        saveMenuItem.setMnemonic('s');
        saveMenuItem.setText("Save");
        fileMenu.add(saveMenuItem);

        saveAsMenuItem.setMnemonic('a');
        saveAsMenuItem.setText("Save As ...");
        saveAsMenuItem.setDisplayedMnemonicIndex(5);
        fileMenu.add(saveAsMenuItem);

        exitMenuItem.setMnemonic('x');
        exitMenuItem.setText("Exit");
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        editMenu.setMnemonic('e');
        editMenu.setText("Edit");

        cutMenuItem.setMnemonic('t');
        cutMenuItem.setText("Cut");
        editMenu.add(cutMenuItem);

        copyMenuItem.setMnemonic('y');
        copyMenuItem.setText("Copy");
        editMenu.add(copyMenuItem);

        pasteMenuItem.setMnemonic('p');
        pasteMenuItem.setText("Paste");
        editMenu.add(pasteMenuItem);

        deleteMenuItem.setMnemonic('d');
        deleteMenuItem.setText("Delete");
        editMenu.add(deleteMenuItem);

        menuBar.add(editMenu);

        helpMenu.setMnemonic('h');
        helpMenu.setText("Help");

        contentMenuItem.setMnemonic('c');
        contentMenuItem.setText("Contents");
        helpMenu.add(contentMenuItem);

        aboutMenuItem.setMnemonic('a');
        aboutMenuItem.setText("About");
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jSplitPane2)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jSplitPane2)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
        System.exit(0);
    }//GEN-LAST:event_exitMenuItemActionPerformed

    private void jTree2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTree2MouseClicked

        TreePath tp = this.jTree2.getPathForLocation(evt.getX(), evt.getY());
        DefaultMutableTreeNodeIdName nodo = (DefaultMutableTreeNodeIdName) tp.getLastPathComponent();
        if (tp != null) {
            this.jButton1.setText(nodo.getId());
            productTable(nodo.getId());

        } else {
            this.jButton1.setText("");
        }


    }//GEN-LAST:event_jTree2MouseClicked

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed

        configurations conf = (configurations) this.configuration.get(this.jTextField1.getText());
        this.jTextField1.setText(conf.getValue());
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

        HTMLEditorPane editor = new HTMLEditorPane();
        JFrame frame = new JFrame();
        frame.add(editor);
        frame.show();
        /*
         * Element desc; Form form = new Form(); form.printForm(); HTMLArea tx=
         * new HTMLArea(form,desc);
         */
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
        // TODO add your handling code here:
        //this.jLabel7.setText(this.jTable2.getValueAt(this.jTable2.getSelectedRow(), 0).toString());
        for (int x = 0; this.bdproducts.size() > x; x++) {
            if (this.jTable1.getValueAt(this.jTable1.getSelectedRow(), 0).toString().equals(this.bdproducts.get(x).getId())) {
                frmProd f = new frmProd(this, true); //= new frmProd();
                f.setCategories(bdcategories);
                f.setProduct(this.bdproducts.get(x));
                f.show();
                this.bdproducts.set(x, f.getProduct());
                return;
            }
        }
    }//GEN-LAST:event_jTable1MouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;


                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(mainForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(mainForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(mainForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(mainForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                try {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    new mainForm().setVisible(true);
                } catch (ClassNotFoundException ex) {
                    Logger.getLogger(mainForm.class.getName()).log(Level.SEVERE, null, ex);
                } catch (InstantiationException ex) {
                    Logger.getLogger(mainForm.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IllegalAccessException ex) {
                    Logger.getLogger(mainForm.class.getName()).log(Level.SEVERE, null, ex);
                } catch (UnsupportedLookAndFeelException ex) {
                    Logger.getLogger(mainForm.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem aboutMenuItem;
    private javax.swing.JMenuItem contentMenuItem;
    private javax.swing.JMenuItem copyMenuItem;
    private javax.swing.JMenuItem cutMenuItem;
    private javax.swing.JMenuItem deleteMenuItem;
    private javax.swing.JMenu editMenu;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JOptionPane jOptionPane1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JSplitPane jSplitPane2;
    private javax.swing.JTable jTable1;
    private javax.swing.JTable jTable3;
    private javax.swing.JTable jTable4;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTree jTree2;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenuItem openMenuItem;
    private javax.swing.JMenuItem pasteMenuItem;
    private javax.swing.JMenuItem saveAsMenuItem;
    private javax.swing.JMenuItem saveMenuItem;
    // End of variables declaration//GEN-END:variables
}
